﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ICTBilling;

public partial class WebForms_Center : System.Web.UI.Page
{
    private static List<ExceptionHandler> ExecutionCollection = new List<ExceptionHandler>();
    protected void Page_Load(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(ShowView);
    }


    protected void SearchImageButton_Click(object sender, ImageClickEventArgs e)
    {
        CenterGridView.PageSize = (PageSizeDropDownList.SelectedIndex == -1 || PageSizeDropDownList.SelectedValue == "0" ? 5 : Convert.ToInt32(PageSizeDropDownList.SelectedValue));
        if (CenterNameTextBox.Text != string.Empty ||
            CenterPassTextBox.Text != string.Empty)
        {
            CenterFormView.ChangeMode(FormViewMode.Insert);
            ClearImageButton.OnClientClick = string.Empty;
        }
        else
            ClearImageButton_Click(sender, e);
    }
    protected void ClearImageButton_Click(object sender, ImageClickEventArgs e)
    {
        CenterNameTextBox.Text = CenterPassTextBox.Text = string.Empty;
        CenterFormView.ChangeMode(FormViewMode.Insert);
        ClearImageButton.OnClientClick = "return false;";
    }
    protected void NewImageButton_Click(object sender, ImageClickEventArgs e)
    {
        MultiView1.SetActiveView(EditView);
        CenterFormView.ChangeMode(FormViewMode.Insert);
        CenterFormView.DataBind();
    }
    protected void CenterGridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        CenterFormView.PageIndex = (CenterGridView.PageSize * CenterGridView.PageIndex) + CenterGridView.SelectedIndex;
        MultiView1.SetActiveView(EditView);
        CenterFormView.ChangeMode(FormViewMode.Edit);
        CenterFormView.DataBind();
        CenterGridView.SelectedIndex = -1;
    }
    protected void CenterEntityDataSource_Command(object sender, EntityDataSourceChangedEventArgs e)
    {
        tbCenter newsItem = e.Entity as tbCenter;
        if (e.Entity != null)
            ExecutionCollection.AddRange(newsItem.Validate(CenterFormView.CurrentMode == FormViewMode.Edit ? ChangeAction.Update : ChangeAction.Insert));

        CenterGridView.DataBind();
        MultiView1.SetActiveView(ShowView);
    }

    protected void CenterFormView_ItemDeleted(object sender, FormViewDeletedEventArgs e)
    {
        CenterFormView.DataBind();
    }
   
}